package com.yc.demo.d0219;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;


/**
 * 1继承
 * 2实现
 * 3配置
 */
@WebServlet("/getWeek.s")
public class GetWeekServlet extends HttpServlet {

    private int a  = 1;

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        a++;

        Date date = new Date();

        String code = req.getParameter("code");
        if (code == null){
            code = "EEE";
        }

        SimpleDateFormat sdf = new SimpleDateFormat("EEE");

        final String format =sdf.format(date);

        resp.setContentType("text/html;charset=utf-8");

        resp.getWriter().printf("第%d次访问   " , a );
        resp.getWriter().print(format);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }
}
